<?php
    class Products extends CI_Model{

     var $prods;
     var $prodPrice;
    
    public function __construct(){
          parent::__construct();
         
           $this->load->database();

      }  
      
      
      function  get_product_detail($id,$info){
          //return product given the id
           $prods = array('pdi'=>array(
                                      'cat_id'=> '0',
                                      'name'=> 'Philippine Daily Inquirer'
                                  ),
                          'mb'=>array(
                                      'cat_id'=> '1',
                                      'name'=> 'Manila Bulletin',
                                  ),
                          'philstar'=>array(
                                      'cat_id'=> '2',
                                      'name'=> 'Philippine Star',
                                  )

                       ); 
            if($info=='name')
              return $prods[$id]['name'];
            else
              return $prods[$id]['cat_id'];
      }

      function get_product_price($typeid,$prodid,$price){

           $prodPrice = array('dispadd'=>array(
                                    'pdi'=>array('wkday_price'=>'371',
                                                 'wkend_price'=>'427'),
                                    'mb'=>array( 'wkday_price'=>'350',
                                                 'wkend_price'=>'450'),
                                    'philstar'=>array('wkday_price'=>'325',
                                                      'wkend_price'=>'425'),
                                    
                                    ),
                           
                            'cladd'=> array(
                                    'pdi'=>array('wkday_price'=>'245',
                                                 'wkend_price'=>'245'),
                                    'mb'=>array('wkday_price'=>'220',
                                                 'wkend_price'=>'220'),
                                    'philstar'=>array('wkday_price'=>'230',
                                                      'wkend_price'=>'230'),
                                    

                                    ),
                            
                            'obt'=> array(
                                    'pdi'=>array('wkday_price'=>'245',
                                                 'wkend_price'=>'245'),
                                    'mb'=>array('wkday_price'=>'220',
                                                 'wkend_price'=>'220'),
                                    'philstar'=>array( 'wkday_price'=>'230',
                                                       'wkend_price'=>'230')
                                    ),
                            
                            
                            
                            );

                    return $prodPrice[$typeid][$prodid][$price];
          
      }
      
      function get_products_by_category($catid){

           $prods = array('news'=>array(
                                      'cat_id'=> '0',
                                      'name'=> 'Philippine Daily Inquirer'
                                  ),
                          'mags'=>array(
                                      'cat_id'=> '1',
                                      'name'=> 'Philippine Daily Inquirer',
                                  ),
                          'tab'=>array(
                                      'cat_id'=> '1',
                                      'name'=> 'Philippine Star',
                                  )

                       );
          
          return $prods;
      }

      function get_adtypes(){
          try{
             

               $query = $this->db->get('AdType');
              foreach($query->result() as $row){
                  echo $row->name . "<br/>";
              }
              
          }catch(Exception $e){
              echo $e;
          }
         
      }


    }


?>

